<%@page import="itsm.isperp.framework.core.context.ContextHolder"%>
<%@ page pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="isperp" uri="/WEB-INF/tlds/isperp.tld"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<div class="header">
	<h2>
		微信企业号参数设置<span><font color="red">（* 为必填项）</font> </span>
	</h2>
</div>
<form action="app/appConfig/save" id="formAppConfig" method="post">

	<table class=" form-table">
		<tbody>
			<tr>
				<td class="td1">是否启用：</td>
				<td class="td2"><input type="radio" id="wechatCpEnable1"
					name="wechatCpEnable" value="1" /><label for="wechatCpEnable1">是</label>

					<input type="radio" id="wechatCpEnable2" name="wechatCpEnable"
					value="0" /><label for="wechatCpEnable2">否</label></td>
			</tr>
			
			<tr>
				<td class="td1">企业号二维码：</td>
				<td class="td2"><isperp:photoUploader imgName="wechatCpQrcode"
						cutType="0" imgWidth="140" imgHeight="140"
						imgSrc="${wechatCpQrcode}" id="wechatCpQrcode" imgPath="wechatCpQrcode"
						imgFormat="png/gif/jpg"></isperp:photoUploader>
				</td>
			</tr>


			<tr>
				<td class="td1">微信Token：</td>
				<td class="td2"><input type="text" id="txtwechatCpToken"
					name="wechatCpToken" value="${wechatCpToken}" maxlength="50"
					style="width:30%" class="required" />
				</td>
				</td>
			</tr>
			<tr>
				<td class="td1">微信AppId：</td>
				<td class="td2"><input type="text" id="txtwechatCpAppId"
					name="wechatCpAppId" value="${wechatCpAppId}" maxlength="50"
					style="width:30%" class="required" />
				</td>
			</tr>
			<tr>
				<td class="td1">AES Key：</td>
				<td class="td2"><input type="text" id="txtwechatCpAesKey"
					name="wechatCpAesKey" value="${wechatCpAesKey}" maxlength="150"
					style="width:30%" class="required" />
				</td>
			</tr>
			<tr>
				<td class="td1">微信Secret：</td>
				<td class="td2"><input type="text" id="txtwechatCpAppSecret"
					name="wechatCpAppSecret" value="${wechatCpAppSecret}"
					maxlength="150" style="width:30%" class="required" />
				</td>
			</tr>
			<tr>
				<td class="td1">AgentId：</td>
				<td class="td2"><input type="text" id="txtwechatCpAgentId"
					name="wechatCpAgentId" value="${wechatCpAgentId}" maxlength="50"
					style="width:50px" class="required" />
				</td>
			</tr>
			<tr>
				<td class="td1">ACCESS_TOKEN：</td>
				<td class="td2"><label id="lbAccessToken">${wechatCpAccessToken}</label><br>
					<input type="button" onclick="resetAccessToken();" value="重置">(有效期为7200秒)
				</td>
			</tr>
		</tbody>
	</table>
	<div class="header">
		<h2>微信企业台工作时间设置</h2>
	</div>
	<table class=" form-table">

		<tr>
			<td class="td1">工作日设定：</td>
			<td class="td2"><input type="radio" value="1"
				name="wechatCpWorkType" id="wechatCpWorkType1"> <label
				for="wechatCpWorkType1">项目工作日历</label> &nbsp;&nbsp; <input
				type="radio" value="2" name="wechatCpWorkType"
				id="wechatCpWorkType2"> <label for="wechatCpWorkType2">7×24小时</label>
			</td>

		</tr>

		<tr>
			<td class="td1">非工作时间自动回复：</td>
			<td class="td2">
				<p>请输入文本，支持参数:config(配置项内容)</p> <textarea
					id="txtwechatCpNoworkTimeNotice" name="wechatCpNoworkTimeNotice"
					class="required" style="width:80%;height:50px">${wechatCpNoworkTimeNotice}</textarea>
			</td>
		</tr>
	</table>

	<div class="header">
		<h2>微信消息通知</h2>
	</div>
	<table class=" form-table">

		<tr>
			<td class="td1">创建工单通知：</td>
			<td class="td2"><textarea id="wechatCpCreateIncidentNotice"
					name="wechatCpCreateIncidentNotice" class="required"
					style="width:80%;height:50px">${wechatCpCreateIncidentNotice}</textarea>
			</td>
		</tr>

	</table>
	<div class="header">
		<h2>全局响应事件设置</h2>
	</div>

</form>
<table class=" form-table">
	<tbody>
		<tr>
			<td class="td1"></td>
			<td class="td2"><button type="submit" id="btnSaveAppConfig"
					class="nui-mainbtn" onclick="btnSaveAppConfigOnclick();"
					name="btnSaveAppConfig" value="保存">&nbsp;&nbsp;&nbsp;保存&nbsp;&nbsp;&nbsp;</button>
			</td>
		</tr>

	</tbody>
</table>

<script type="text/javascript">
	var rowTemplate = '<tr>' + '<td><input type="text" name="messageContentTitle">' + '</td>' + '<td><input type="text" name="messageContentDesc">' + '</td>' + '<td><input type="text" name="messageContentPicurl">' + '	<a class="nui-txt-link" href="">上传</a></td>' + '<td><input type="text" name="messageContentUrl"></td>' + '<td><span class="ui-icon ui-icon-trash"' + '	onclick="removeMessageContentRow(this)"></span>' + '</td>' + '</tr>';

	$("input[name=wechatCpWorkType][value=${wechatCpWorkType}]").attr("checked", 'checked');

	$("input[name=wechatCpEnable][value=${wechatCpEnable}]").attr("checked", 'checked');

	function createMessageContentRow() {
		$("#messageContentTable").append(rowTemplate);
	}

	function removeMessageContentRow(obj) {
		$(obj).parent().parent().remove();
	}
	function btnSaveAppConfigOnclick() {
		isperp.showLoading();
		isperp.submitForm({
			formId : "formAppConfig",
			success : function(data) {
				if (data.success) {

					isperp.hideLoading();
					isperp.alert("保存成功！");
				} else {
					isperp.alert(data.tata);
				}
			},
			error : function() {

				isperp.hideLoading();
				isperp.alert("保存失败！");
			}
		});
	}

	function resetAccessToken() {
		$.post("wechat/cp/config/resetAccessToken", function(data) {
			$("#lbAccessToken").text(data.data);
			isperp.alert("重置成功");

		});
	}
</script>










